package io.stream;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @Package javaSE.io.stream
 * @Author shimmer
 * @Date 2020/5/28 16:09
 * @TODO
 */
public class FileStreamTest04 {
    public static void main(String[] args) {
        FileOutputStreamTest();
    }
    
    public static void FileOutputStreamTest(){
        String Path = "src\\main\\java\\javaSE\\io\\stream";
        File file1 = new File(Path,"test02.txt");
        File file2 = new File(Path,"test03.txt");
        try (FileInputStream fis = new FileInputStream(file1);
             FileOutputStream fos = new FileOutputStream(file2);
             ){
            byte[] buf = new byte[4];
            int hasRead = 0;
            while (0<(hasRead = fis.read(buf))){
                fos.write(buf,0,hasRead);
            }
            System.out.println("写入成功！");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
